<template>
    <view class="pub_page pub_set">
        <pub-head headerName="set" :headerConfig="headerConfig"></pub-head>
        <div class="page_box page_box_scroll" :style="{ 'height': `calc(100vh - ${headerHeight})` }">
            <div class="lis_div">
                <div class="title">首页头部背景配置</div>
                <div class="lis">
                    <div class="li" @click="$comFun.openWin('/pages/mine/bg')">
                        <div class="left">
                            <image class="img" mode="aspectFit" :src="standing == 'user' ? bg_user : bg_manage" />
                        </div>
                        <div class="right">
                            <image class="right_icon" mode="aspectFit"
                                src="https://sppcp-1322907932.cos.ap-beijing.myqcloud.com/app/img_24.png" />
                        </div>
                    </div>
                </div>
            </div>
            <!-- <div class="lis_div">
                <div class="title">功能配置</div>
                <div class="lis">
                    <div class="li">
                        <div class="left">用户合闸断闸</div>
                        <div class="right">不允许
                            <image class="right_icon" mode="aspectFit"
                                src="https://sppcp-1322907932.cos.ap-beijing.myqcloud.com/app/img_24.png" />
                        </div>
                    </div>
                </div>
            </div> -->
            <div class="lis_div" v-if="noticeList.length">
                <div class="title">协议信息</div>
                <div class="lis">
                    <div class="li" v-for="(li, key) in noticeList" :key="key"
                        @click="$comFun.openWin('/pages/mine/document', { noticeId: li.noticeId })">
                        <div class="left">{{ li.title }}</div>
                        <div class="right">
                            <image class="right_icon" mode="aspectFit"
                                src="https://sppcp-1322907932.cos.ap-beijing.myqcloud.com/app/img_24.png" />
                        </div>
                    </div>
                </div>
            </div>
            <!-- <div class="lis_div">
                <div class="title">语言选择</div>
                <div class="lis">
                    <div class="li">
                        <div class="left">语言</div>
                        <div class="right">中文简体
                            <image class="right_icon" mode="aspectFit"
                                src="https://sppcp-1322907932.cos.ap-beijing.myqcloud.com/app/img_24.png" />
                        </div>
                    </div>
                </div>
            </div> -->
            <!-- <div class="lis_div">
                <div class="title">推送设置</div>
                <div class="lis">
                    <div class="li">
                        <div class="left">微信通知</div>
                        <div class="right">
                            <image class="switch" mode="aspectFit"
                                src="https://sppcp-1322907932.cos.ap-beijing.myqcloud.com/app/img_62.png" />
                        </div>
                    </div>
                    <div class="li">
                        <div class="left">短信通知</div>
                        <div class="right">
                            <image class="switch" mode="aspectFit"
                                src="https://sppcp-1322907932.cos.ap-beijing.myqcloud.com/app/img_61.png" />
                        </div>
                    </div>
                </div>
            </div> -->
            <div style="height:200rpx"></div>
            <div class="pub_btns" :style="{ 'bottom': `calc(${statusBottomHeight}px + 32rpx)` }">
                <div class="pub_btn pub_btn_big" @click="toLogout">退出登录</div>
            </div>
        </div>
    </view>
</template>

<script>
export default {
    data() {
        return {
            headerConfig: {
                title: '通用设置',//标题栏内容
                header_color: '#fff'
            },
            headerHeight: getApp().globalData.headerHeight,
            statusBottomHeight: getApp().globalData.statusBottomHeight,
            standing: this.$store.state.standing,

            bg_user: '',
            bg_manage: '',

            noticeList: []
        };
    },
    onLoad() {
        // 支付宝小程序设置状态栏文字颜色
        this.$comFun.setZfbNavigationBar();

        this.getNoticeList();
    },
    onShow() {
        if (this.$store.state.standing == 'user') {
            const bg_user = uni.getStorageSync('bg_user');
            this.bg_user = bg_user ? bg_user : this.$store.state.bg_normal_user;
            console.log(bg_user, this.bg_user);
        } else if (this.$store.state.standing == 'manage') {
            const bg_manage = uni.getStorageSync('bg_manage');
            this.bg_manage = bg_manage || this.$store.state.bg_normal_manage;
            console.log(bg_manage, this.bg_manage);
        }
    },
    methods: {
        async getNoticeList() {
            const res = await this.$request.get('mobile/user_center/getNoticeList', {
                pageNum: 1,
                pageSize: 1000,
            });
            // console.log(res);
            if (res.code == 200) {
                this.noticeList = res.data?.data || [];
            }
        },
        toLogout() {
            const that = this;
            uni.showModal({
                title: '提示',
                content: '是否确定退出登录？',
                success: function (res) {
                    if (res.confirm) {
                        that.$comFun.toast('退出成功');
                        that.$store.dispatch('setStanding', 'user');
                        uni.setStorageSync('userStanding', 'user');
                        that.$comFun.clearUserInfo();
                    }
                }
            });
        },
    },
};
</script>

<style lang="scss" scoped>
@import "@/common/css/mine.scss";
</style>
